/**
 * @author   zhangyp
 * @created  2013-11-1 下午5:31:44
 * @email    zviolet@163.com
 * TODO      文件目录选择
 */
package com.bible.fire.pad.activity.aspect;

import java.io.File;  
import java.util.ArrayList;  
import java.util.List;  
  
import android.app.AlertDialog;  
import android.content.DialogInterface;  
import android.content.Intent;  
import android.graphics.Color;  
import android.os.Bundle;  
import android.view.View;  
import android.view.View.OnClickListener;  
import android.view.ViewGroup;
import android.widget.AdapterView;  
import android.widget.AdapterView.OnItemClickListener;  
import android.widget.Button;  
import android.widget.ImageView;  
import android.widget.LinearLayout;  
import android.widget.ListView;  
import android.widget.TextView;  
import android.widget.Toast; 

import com.bible.fire.R;
import com.bible.fire.pad.activity.BaseActivity;
import com.bible.fire.util.SystemConstant;
import com.bible.fire.util.ToastUtil;
import com.bible.fire.util.file.FileBrowseAdapter;
import com.bible.fire.util.file.FileBrowseHelper;

public class FileBrowserActivity extends BaseActivity {
 
    private TextView mPath;    
  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        this.setContentView(R.layout.filelist);  
          
        //FileBrowseHelper.addDirBrowseView( this , (ViewGroup)this.findViewById(R.id.filebrowser) );
        String fileDir = SystemConstant.SDCARD_ROOT_PATH + "/doc";
        FileBrowseHelper.addFileBrowseView( this , (ViewGroup)this.findViewById(R.id.filebrowser), fileDir );
        mPath = (TextView)this.findViewById(R.id.mPath);
        this.setTitle("请选择保存目录:");  
        Button ok = (Button)this.findViewById(R.id.fileok);  
        ok.setPadding(0, 5, 0, 5);  
        ok.setOnClickListener(new OnClickListener(){  
            @Override  
            public void onClick(View v) {  
                    ToastUtil.showMsg(FileBrowserActivity.this, mPath.getText().toString());
                    Intent i = new Intent();  
                    Bundle b = new Bundle();    
                    b.putString("savePath", mPath.getText().toString());    
                    b.putString("url", FileBrowserActivity.this.getIntent().getStringExtra("url"));    
                    b.putString("fileName", FileBrowserActivity.this.getIntent().getStringExtra("fileName"));    
                    i.putExtras(b);  
                    FileBrowserActivity.this.setResult(RESULT_OK, i);  
                    FileBrowserActivity.this.finish();  
                
                  
            }  
        });  
        Button cancel = (Button)this.findViewById(R.id.filecancel);  
        cancel.setPadding(0, 5, 0, 5);  
        cancel.setOnClickListener(new OnClickListener(){  
            @Override  
            public void onClick(View v) {  
                FileBrowserActivity.this.finish();  
            }  
        });  
    }  
 
	

}
